package ch.zbw.sysventory.server.scanner.xml.impl;

import java.io.StringReader;

import org.exolab.castor.xml.Unmarshaller;
import org.xml.sax.InputSource;

import ch.zbw.sysventory.server.scanner.xml.ScanResultXmlReader;
import ch.zbw.sysventory.transport.model.ScanResult;

public class ScanResultXmlReaderImpl implements ScanResultXmlReader {

	@Override
	public ScanResult readScanResultXml(String xmlAsString) throws Exception {
		StringReader stringReader = new StringReader(xmlAsString);
		InputSource inputSource = new InputSource(stringReader);
		Unmarshaller unmarshaller = new Unmarshaller(ScanResult.class);
		ScanResult scanResult = (ScanResult) unmarshaller.unmarshal(inputSource);
		return scanResult;
	}

}
